package com.tangguangdi.base.core.controller;

import com.tangguangdi.base.common.basic.Result;
import com.tangguangdi.base.common.core.AppController;
import com.tangguangdi.base.core.annotation.Apis;
import com.tangguangdi.base.core.annotation.GetApi;
import com.tangguangdi.base.core.register.ModeServer;
import jakarta.annotation.Resource;

import java.util.ArrayList;
import java.util.List;

/**
 * 核心接口文档服务
 */
@Apis(path = "max-core/api", name = "接口文档")
public class MatrixApiController {

    /**
     * 模式服务
     */
    @Resource
    private ModeServer modeServer;

    /**
     * 无参构造器
     */
    public MatrixApiController() {
    }

    /**
     * 接口列表
     *
     * @return AppDoc
     */
    @GetApi(name = "控制器列表")
    public Result<List<AppController>> appControllers() {
        List<AppController> appControllers = new ArrayList<>();
        for (AppController appController : modeServer.getAppDoc().getAppControllers()) {
            if(!appController.getCode().equals("MatrixModeServer") &&
                    !appController.getCode().equals("MatrixApiController")){
                appControllers.add(appController);
            }
        }
        return new Result<List<AppController>>().setSuccess(true).setData(appControllers);
    }
}
